﻿AjaxControlToolkit.TextBoxWatermarkBehavior.MvcAjaxHandleSubmit = function(form, evt, ajaxOptions) {
    var components = Sys.Application.getComponents();
    for (var i = 0; i < components.length; i++) {
        var component = components[i];
        if (AjaxControlToolkit.TextBoxWatermarkBehavior.isInstanceOfType(component)) {
            component._onSubmit();
        }
    }
    AjaxControlToolkit.TextBoxWatermarkBehavior._mvcAjaxHandleSubmit(form, evt, ajaxOptions)
}

AjaxControlToolkit.TextBoxWatermarkBehavior.HookMvcAjaxEvents = function() {
    if ((typeof (Sys.Mvc.AsyncForm.handleSubmit) == 'function') && !AjaxControlToolkit.TextBoxWatermarkBehavior._mvcAjaxHandleSubmit) {
        AjaxControlToolkit.TextBoxWatermarkBehavior._mvcAjaxHandleSubmit = Sys.Mvc.AsyncForm.handleSubmit;
        Sys.Mvc.AsyncForm.handleSubmit = AjaxControlToolkit.TextBoxWatermarkBehavior.MvcAjaxHandleSubmit;
    }
}

Sys.Application.add_init(AjaxControlToolkit.TextBoxWatermarkBehavior.HookMvcAjaxEvents);